package com.synesthesiaconsulting.gwt.resources.client;

import com.google.gwt.user.client.Window;

/**
 * Created by IntelliJ IDEA.
 * User: ageer
 * Date: Jul 24, 2008
 * Time: 5:19:08 PM
 * To change this template use File | Settings | File Templates.
 */
public class GWTUrlActionUnit implements IActionUnit {
    private String url;
    private String target;
    private String options;

    public GWTUrlActionUnit() {
        url = "";
        target = "_self";
        options = "";
    }
    public GWTUrlActionUnit(String url) {
        if (url == null) url = "";
        this.url = url;
        target = "_self";
        options = "";
    }
    public GWTUrlActionUnit(String url, String target) {
        if (url == null) url = "";
        if (target == null) target = "";
        this.url = url;
        this.target = target;
        this.options = "";
    }
    public GWTUrlActionUnit(String url, String target, String options) {
        if (url == null) url = "";
        if (target == null) target = "";
        if (options == null) options = "";
        this.url = "";
        this.target = target;
        this.options = options;
    }

    public void applyAction() {
        Window.open(url,target,options);
    }

    public void applyAction(Object applyTo) {
        applyAction();
    }

    public String toString() {
        return "openURL(" + url + ","+target+","+options+")";
    }

}
